namespace Csharp01._0923;

public class Demo
{
    public void Test01()
    {
        Console.WriteLine("100到999之间的水仙花数：");
        for (int i = 100; i <= 999; i++)
        {
            int hundreds = i / 100;        
            int tens = (i / 10) % 10;     
            int units = i % 10;           
            
            if (i == (hundreds * hundreds * hundreds + tens * tens * tens + units * units * units))
            {
                Console.WriteLine(i);
            }
        }
    }
    public  void Test02()
    {
        Console.Write("请输入年份：");
        
        string input = Console.ReadLine();
        
        
        if (int.TryParse(input, out int year))
        {
            
            bool flag = (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
            
            if (flag)
            {
                Console.WriteLine($"{year}年是闰年");
            }
            else
            {
                Console.WriteLine($"{year}年不是闰年");
            }
        }
        else
        {
            Console.WriteLine("输入无效，请输入有效的年份数字");
        }
    }
    public void Test03()
    { 
        const double originalPrice = 8800;
        Console.Write("请输入出行月份(1-12)：");
        string monthInput = Console.ReadLine();
        Console.Write("请选择交通方式(1-航班出行, 2-动车出行)：");
        string transportInput = Console.ReadLine();

        if (int.TryParse(monthInput, out int month) && int.TryParse(transportInput, out int transport))
        {
            if (month >= 1 && month <= 12 && (transport == 1 || transport == 2))
            {
                bool isPeakSeason = (month >= 5 && month <= 10);
                double discount = 1.0;

                if (isPeakSeason)
                {
                    if (transport == 1) // 航班出行
                        discount = 0.9;
                    else // 动车出行
                        discount = 0.75;
                }
                else
                {
                    if (transport == 1) // 航班出行
                        discount = 0.6;
                    else // 动车出行
                        discount = 0.3;
                }

                double finalPrice = originalPrice * discount;
                string season = isPeakSeason ? "旺季" : "淡季";
                string transportMethod = transport == 1 ? "航班出行" : "动车出行";

                Console.WriteLine($"旅游原价：{originalPrice}元");
                Console.WriteLine($"出行时间：{month}月({season})");
                Console.WriteLine($"交通方式：{transportMethod}");
                Console.WriteLine($"折扣：{discount * 10}折");
                Console.WriteLine($"最终价格：{finalPrice}元");
            }
            else
            {
                Console.WriteLine("输入的月份或交通方式无效！");
            }
        }
        else
        {
            Console.WriteLine("输入格式错误，请输入有效的数字！");
        }
    }
}

